package pub.developers.forum.facade.validator;

import pub.developers.forum.api.request.user.*;
import pub.developers.forum.common.support.CheckUtil;


public class UserValidator {

    public static void register(UserRegisterRequest request) {
        if (request.getCode() != null && !request.getCode().isEmpty()) //如果用户选择通过邮箱验证码注册
        {
            CheckUtil.checkParamToast(request, "request");
            CheckUtil.checkParamToast(request.getEmail(), "email");
//            CheckUtil.checkParamToast(request.getNickname(), "nickname");
//            CheckUtil.checkParamToast(request.getPassword(), "password");
        }
        else
        {
            CheckUtil.checkParamToast(request, "request");
            CheckUtil.checkParamToast(request.getEmail(), "email");
            CheckUtil.checkParamToast(request.getNickname(), "nickname");
            CheckUtil.checkParamToast(request.getPassword(), "password");
        }
    }

    public static void emailLogin(UserEmailLoginRequest request) {
        CheckUtil.checkParamToast(request, "request");
        CheckUtil.checkParamToast(request.getEmail(), "email");
        CheckUtil.checkParamToast(request.getPassword(), "password");
    }


    //修改个人信息2.0的参数校验
    public static void updateInfo2(UserUpdateInfoRequest request){
        CheckUtil.checkParamToast(request, "request");
        CheckUtil.checkParamToast(request.getEmail() , "email");
    }


    public static void updateInfo(UserUpdateInfoRequest request) {
        CheckUtil.checkParamToast(request.getNickname(), "nickname"); //昵称
    }

    public static void updatePwd(UserUpdatePwdRequest request) {
        CheckUtil.checkParamToast(request, "request");
        CheckUtil.checkParamToast(request.getOldPassword(), "oldPassword");
        CheckUtil.checkParamToast(request.getNewPassword(), "newPassword");
    }

    public static void updateRole(UserUpdateRoleRequest request) {
        CheckUtil.checkParamToast(request, "request");
        CheckUtil.checkParamToast(request.getUserId(), "userId");
        CheckUtil.checkParamToast(request.getRole(), "role");
    }

    public static void adminPage(UserAdminPageRequest request) {

    }

    public static void logout(UserTokenLogoutRequest request) {
        CheckUtil.checkParamToast(request, "request");
        CheckUtil.checkParamToast(request.getToken(), "token");
    }
}
